package impl.locale;

import data.IntegerDataSetGenerator;
import impl.HeapSorter;
import provider.SorterProviderImpl;
import test.Benchmark;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class OrdenarConLocale {

    public static void main(String[] args) {
        IntegerDataSetGenerator dataGenerator = new IntegerDataSetGenerator();
        SorterProviderImpl sorterProvider = new SorterProviderImpl();
        HeapSorter sorter = new HeapSorter();
        algorithmTest(dataGenerator, sorter);
    }

    private static void algorithmTest(IntegerDataSetGenerator dataGenerator, HeapSorter sorters) {
        System.out.println("Resultado de las pruebas de HeapSort:");
        System.out.println("");
        randomTesting(dataGenerator, sorters);
    }

    private static void randomTesting(IntegerDataSetGenerator dataGenerator, HeapSorter sorter) {
        List palabras = makeWordList();
        List list2 = palabras;
        Benchmark benchMark = new Benchmark();
        sorter.addSorterListener(benchMark);
        analiseList(dataGenerator, sorter, palabras, list2);
    }

    private static void analiseList(IntegerDataSetGenerator dataGenerator, HeapSorter sorter, List palabras, List list2) {
        sorter.sort(Locale.FRENCH, dataGenerator.getComparator(), palabras);
        System.out.println("Locale FRENCH");
        show(list2);
        sorter.sort(Locale.ENGLISH, dataGenerator.getComparator(), palabras);
        System.out.println("Locale ENGLISH");
        show(list2);
        //sorter.sort(Locale.forLanguageTag("ES"), dataGenerator.getComparator(), palabras);
        System.out.println("Palabras ordenadas con Locale ESPAÑOL");
        show(list2);
    }

    private static List makeWordList() {
        List palabras = new ArrayList();
        palabras.add("llamado");
        palabras.add("lunes");
        palabras.add("péché");
        palabras.add("pêche");
        palabras.add("cerca");
        palabras.add("champán");
        palabras.add("clamor");
        return palabras;
    }

    private static void show(List list) {
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

    }

}



